package com.ciwong.epaper.modules.epaper.adapter;

import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.ciwong.epaper.modules.epaper.bean.EpaperInfo;
import com.ciwong.epaper.modules.epaper.ui.bookcase.ItemBookCase;

/**
 * Created by Administrator on 2017/8/22.
 */

public class BookCaseAdapter extends BaseRvAdapter<RecyclerView.ViewHolder,ItemBookCase,EpaperInfo>{


    private Fragment mFragment;
    private  float bookWidth;
    private  float bookHeight;

    private boolean isEditMode=false;



    public BookCaseAdapter(Fragment fragment, float width, float height) {
        mRowDataCount=3;
        mFragment=fragment;
        bookWidth=width;
        bookHeight=height;
    }

    public void setEditMode(boolean editMode) {
        isEditMode = editMode;
    }

    @Override
    protected int getTopItemCount() {
        return 0;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BookCaseHolder(new ItemBookCase(parent.getContext(),mFragment,bookWidth,bookHeight));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        ((BookCaseHolder) holder).mItemBookCase.update(getItemDataList(position),isEditMode);
    }


    static class BookCaseHolder extends RecyclerView.ViewHolder {
        ItemBookCase mItemBookCase;
        public BookCaseHolder(ItemBookCase itemView) {
            super(itemView);
            mItemBookCase=itemView;
        }
    }

}
